<?php
/**
 +------------------------------------------------------------------------------
 * Session实现类
 +------------------------------------------------------------------------------
 */
class ISession extends Model
{
	/**
     +----------------------------------------------------------
     * 判断Session是否存在
     +----------------------------------------------------------
     * @param $name session名字
     +----------------------------------------------------------
     * @return bool
     +----------------------------------------------------------
     */
    public static function has($name)
    {
    	return (false == self::get($name))?false:true;
    }
    
	/**
     +----------------------------------------------------------
     * 取得session的值
     +----------------------------------------------------------
     * @param $name session名字
     +----------------------------------------------------------
     * @return string session的值
     +----------------------------------------------------------
     */
    public static function get($name){
    	if(isset($_SESSION[$name])){
    		return unserialize(base64_decode($_SESSION[$name]));
    	}else{
    		return false;
    	}
    }

	/**
     +----------------------------------------------------------
     * 取得session的值
     +----------------------------------------------------------
     * @param $name session名字
     +----------------------------------------------------------
     * @return string session的值
     +----------------------------------------------------------
     */
    public static function set($name,$val){
    	$_SESSION[$name] = base64_encode(serialize($val));
    }
    
    /**
     +----------------------------------------------------------
     * 判断Session是否存在
     +----------------------------------------------------------
     * @param $name session名字
     +----------------------------------------------------------
     * @return bool
     +----------------------------------------------------------
     */
    public static function fre($name)
    {
    	unset($_SESSION[$name]);
    }
}
?>